﻿using System;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using System.ComponentModel;
using System.Data;
using DevExpress.XtraEditors;
using DevExpress.XtraEditors.Controls;
using DevExpress.XtraEditors.Repository;

namespace CommonSLT
{
    public delegate void dgCopyMyDialogMessageToClipBoard();

    public class MessageForm : DevExpress.XtraEditors.XtraForm
    {
        #region private variants
        private string caption = "";
        private string content = "";
        private MyDialogButtons myDialogButtons = MyDialogButtons.OK;
        private MyDialogIcon myDialogIcon = MyDialogIcon.None;
        private MyDialogFocus myDialogFocus = MyDialogFocus.OK;
        private MyDialogResult myDialogResult = MyDialogResult.OK;
        public event MyDialogEventHandler MyDialogEvent = null;
        private dgCopyMyDialogMessageToClipBoard mCopyMyDialogMessageToClipBoard = null;
        #endregion private variants
        //==========================================================================

        #region control
        private DevExpress.XtraEditors.PanelControl pnContent2;
        private DevExpress.XtraEditors.PanelControl pnButton;
        private DevExpress.XtraEditors.PanelControl pnButton1;
        private DevExpress.XtraEditors.PanelControl pnBtnYes;
        private DevExpress.XtraEditors.SimpleButton btnYes;
        private DevExpress.XtraEditors.PanelControl pnBtnClose;
        private DevExpress.XtraEditors.SimpleButton btnClose;
        private DevExpress.XtraEditors.PanelControl pnBtnNo;
        private DevExpress.XtraEditors.SimpleButton btnNo;
        private IContainer components;
        private PanelControl pnBtnOK;
        private SimpleButton btnOK;
        private LabelControl lblIcon;
        private PanelControl pnIcon;
        private PanelControl panelControl2;
        private LabelControl lblContent;
        private PanelControl pnCopyToClipboard;
        private SimpleButton btnCopyToClipboard;
        private DevExpress.XtraEditors.PanelControl pnContent;

        private void InitializeComponent()
        {
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MessageForm));
            this.pnButton = new DevExpress.XtraEditors.PanelControl();
            this.pnButton1 = new DevExpress.XtraEditors.PanelControl();
            this.pnCopyToClipboard = new DevExpress.XtraEditors.PanelControl();
            this.btnCopyToClipboard = new DevExpress.XtraEditors.SimpleButton();
            this.pnBtnOK = new DevExpress.XtraEditors.PanelControl();
            this.btnOK = new DevExpress.XtraEditors.SimpleButton();
            this.pnBtnYes = new DevExpress.XtraEditors.PanelControl();
            this.btnYes = new DevExpress.XtraEditors.SimpleButton();
            this.pnBtnNo = new DevExpress.XtraEditors.PanelControl();
            this.btnNo = new DevExpress.XtraEditors.SimpleButton();
            this.pnBtnClose = new DevExpress.XtraEditors.PanelControl();
            this.btnClose = new DevExpress.XtraEditors.SimpleButton();
            this.pnContent = new DevExpress.XtraEditors.PanelControl();
            this.pnContent2 = new DevExpress.XtraEditors.PanelControl();
            this.panelControl2 = new DevExpress.XtraEditors.PanelControl();
            this.lblContent = new DevExpress.XtraEditors.LabelControl();
            this.pnIcon = new DevExpress.XtraEditors.PanelControl();
            this.lblIcon = new DevExpress.XtraEditors.LabelControl();
            ((System.ComponentModel.ISupportInitialize)(this.pnButton)).BeginInit();
            this.pnButton.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.pnButton1)).BeginInit();
            this.pnButton1.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.pnCopyToClipboard)).BeginInit();
            this.pnCopyToClipboard.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.pnBtnOK)).BeginInit();
            this.pnBtnOK.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.pnBtnYes)).BeginInit();
            this.pnBtnYes.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.pnBtnNo)).BeginInit();
            this.pnBtnNo.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.pnBtnClose)).BeginInit();
            this.pnBtnClose.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.pnContent)).BeginInit();
            this.pnContent.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.pnContent2)).BeginInit();
            this.pnContent2.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.panelControl2)).BeginInit();
            this.panelControl2.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.pnIcon)).BeginInit();
            this.pnIcon.SuspendLayout();
            this.SuspendLayout();
            // 
            // pnButton
            // 
            this.pnButton.Appearance.BackColor = System.Drawing.Color.Transparent;
            this.pnButton.Appearance.Options.UseBackColor = true;
            this.pnButton.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
            this.pnButton.Controls.Add(this.pnButton1);
            this.pnButton.Dock = System.Windows.Forms.DockStyle.Bottom;
            this.pnButton.Location = new System.Drawing.Point(0, 61);
            this.pnButton.Name = "pnButton";
            this.pnButton.Padding = new System.Windows.Forms.Padding(3, 1, 3, 3);
            this.pnButton.Size = new System.Drawing.Size(558, 43);
            this.pnButton.TabIndex = 0;
            // 
            // pnButton1
            // 
            this.pnButton1.Appearance.BackColor = System.Drawing.Color.Transparent;
            this.pnButton1.Appearance.Options.UseBackColor = true;
            this.pnButton1.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
            this.pnButton1.Controls.Add(this.pnCopyToClipboard);
            this.pnButton1.Controls.Add(this.pnBtnOK);
            this.pnButton1.Controls.Add(this.pnBtnYes);
            this.pnButton1.Controls.Add(this.pnBtnNo);
            this.pnButton1.Controls.Add(this.pnBtnClose);
            this.pnButton1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.pnButton1.Location = new System.Drawing.Point(3, 1);
            this.pnButton1.Name = "pnButton1";
            this.pnButton1.Size = new System.Drawing.Size(552, 39);
            this.pnButton1.TabIndex = 0;
            // 
            // pnCopyToClipboard
            // 
            this.pnCopyToClipboard.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
            this.pnCopyToClipboard.Controls.Add(this.btnCopyToClipboard);
            this.pnCopyToClipboard.Dock = System.Windows.Forms.DockStyle.Left;
            this.pnCopyToClipboard.Location = new System.Drawing.Point(0, 0);
            this.pnCopyToClipboard.Name = "pnCopyToClipboard";
            this.pnCopyToClipboard.Padding = new System.Windows.Forms.Padding(3);
            this.pnCopyToClipboard.Size = new System.Drawing.Size(135, 39);
            this.pnCopyToClipboard.TabIndex = 5;
            // 
            // btnCopyToClipboard
            // 
            this.btnCopyToClipboard.Appearance.Font = new System.Drawing.Font("Arial", 9F);
            this.btnCopyToClipboard.Appearance.Options.UseFont = true;
            this.btnCopyToClipboard.Dock = System.Windows.Forms.DockStyle.Fill;
            this.btnCopyToClipboard.Image = global::CommonSLT.Properties.Resources.Copy;
            this.btnCopyToClipboard.ImageLocation = DevExpress.XtraEditors.ImageLocation.MiddleLeft;
            this.btnCopyToClipboard.Location = new System.Drawing.Point(3, 3);
            this.btnCopyToClipboard.Name = "btnCopyToClipboard";
            this.btnCopyToClipboard.Size = new System.Drawing.Size(129, 33);
            this.btnCopyToClipboard.TabIndex = 1;
            this.btnCopyToClipboard.Text = "Copy Nội Dung";
            this.btnCopyToClipboard.ToolTip = "Copy nội dung thông báo để có thể dán ra ngoài";
            this.btnCopyToClipboard.Click += new System.EventHandler(this.btnCopyToClipboard_Click);
            // 
            // pnBtnOK
            // 
            this.pnBtnOK.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
            this.pnBtnOK.Controls.Add(this.btnOK);
            this.pnBtnOK.Dock = System.Windows.Forms.DockStyle.Right;
            this.pnBtnOK.Location = new System.Drawing.Point(164, 0);
            this.pnBtnOK.Name = "pnBtnOK";
            this.pnBtnOK.Padding = new System.Windows.Forms.Padding(3);
            this.pnBtnOK.Size = new System.Drawing.Size(97, 39);
            this.pnBtnOK.TabIndex = 4;
            // 
            // btnOK
            // 
            this.btnOK.Appearance.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.btnOK.Appearance.Options.UseFont = true;
            this.btnOK.Dock = System.Windows.Forms.DockStyle.Fill;
            this.btnOK.Image = global::CommonSLT.Properties.Resources.Yes;
            this.btnOK.ImageLocation = DevExpress.XtraEditors.ImageLocation.MiddleCenter;
            this.btnOK.Location = new System.Drawing.Point(3, 3);
            this.btnOK.Name = "btnOK";
            this.btnOK.Size = new System.Drawing.Size(91, 33);
            this.btnOK.TabIndex = 1;
            this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
            // 
            // pnBtnYes
            // 
            this.pnBtnYes.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
            this.pnBtnYes.Controls.Add(this.btnYes);
            this.pnBtnYes.Dock = System.Windows.Forms.DockStyle.Right;
            this.pnBtnYes.Location = new System.Drawing.Point(261, 0);
            this.pnBtnYes.Name = "pnBtnYes";
            this.pnBtnYes.Padding = new System.Windows.Forms.Padding(3);
            this.pnBtnYes.Size = new System.Drawing.Size(97, 39);
            this.pnBtnYes.TabIndex = 1;
            // 
            // btnYes
            // 
            this.btnYes.Appearance.Font = new System.Drawing.Font("Arial", 9F);
            this.btnYes.Appearance.Options.UseFont = true;
            this.btnYes.Dock = System.Windows.Forms.DockStyle.Fill;
            this.btnYes.Image = global::CommonSLT.Properties.Resources.Yes;
            this.btnYes.Location = new System.Drawing.Point(3, 3);
            this.btnYes.Name = "btnYes";
            this.btnYes.Size = new System.Drawing.Size(91, 33);
            this.btnYes.TabIndex = 1;
            this.btnYes.Text = "Có";
            this.btnYes.Click += new System.EventHandler(this.btnYes_Click);
            // 
            // pnBtnNo
            // 
            this.pnBtnNo.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
            this.pnBtnNo.Controls.Add(this.btnNo);
            this.pnBtnNo.Dock = System.Windows.Forms.DockStyle.Right;
            this.pnBtnNo.Location = new System.Drawing.Point(358, 0);
            this.pnBtnNo.Name = "pnBtnNo";
            this.pnBtnNo.Padding = new System.Windows.Forms.Padding(3);
            this.pnBtnNo.Size = new System.Drawing.Size(97, 39);
            this.pnBtnNo.TabIndex = 2;
            // 
            // btnNo
            // 
            this.btnNo.Appearance.Font = new System.Drawing.Font("Arial", 9F);
            this.btnNo.Appearance.Options.UseFont = true;
            this.btnNo.Dock = System.Windows.Forms.DockStyle.Fill;
            this.btnNo.Image = global::CommonSLT.Properties.Resources.No;
            this.btnNo.Location = new System.Drawing.Point(3, 3);
            this.btnNo.Name = "btnNo";
            this.btnNo.Size = new System.Drawing.Size(91, 33);
            this.btnNo.TabIndex = 2;
            this.btnNo.Text = "Không";
            this.btnNo.Click += new System.EventHandler(this.btnNo_Click);
            // 
            // pnBtnClose
            // 
            this.pnBtnClose.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
            this.pnBtnClose.Controls.Add(this.btnClose);
            this.pnBtnClose.Dock = System.Windows.Forms.DockStyle.Right;
            this.pnBtnClose.Location = new System.Drawing.Point(455, 0);
            this.pnBtnClose.Name = "pnBtnClose";
            this.pnBtnClose.Padding = new System.Windows.Forms.Padding(3);
            this.pnBtnClose.Size = new System.Drawing.Size(97, 39);
            this.pnBtnClose.TabIndex = 3;
            // 
            // btnClose
            // 
            this.btnClose.Appearance.Font = new System.Drawing.Font("Arial", 9F);
            this.btnClose.Appearance.Options.UseFont = true;
            this.btnClose.Dock = System.Windows.Forms.DockStyle.Fill;
            this.btnClose.Image = global::CommonSLT.Properties.Resources.Exit;
            this.btnClose.Location = new System.Drawing.Point(3, 3);
            this.btnClose.Name = "btnClose";
            this.btnClose.Size = new System.Drawing.Size(91, 33);
            this.btnClose.TabIndex = 3;
            this.btnClose.Text = "Đóng";
            this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
            // 
            // pnContent
            // 
            this.pnContent.Appearance.BackColor = System.Drawing.Color.Transparent;
            this.pnContent.Appearance.Options.UseBackColor = true;
            this.pnContent.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
            this.pnContent.Controls.Add(this.pnContent2);
            this.pnContent.Dock = System.Windows.Forms.DockStyle.Fill;
            this.pnContent.Location = new System.Drawing.Point(0, 0);
            this.pnContent.Name = "pnContent";
            this.pnContent.Padding = new System.Windows.Forms.Padding(3);
            this.pnContent.Size = new System.Drawing.Size(558, 61);
            this.pnContent.TabIndex = 4;
            // 
            // pnContent2
            // 
            this.pnContent2.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
            this.pnContent2.Controls.Add(this.panelControl2);
            this.pnContent2.Controls.Add(this.pnIcon);
            this.pnContent2.Dock = System.Windows.Forms.DockStyle.Fill;
            this.pnContent2.Location = new System.Drawing.Point(3, 3);
            this.pnContent2.Name = "pnContent2";
            this.pnContent2.Padding = new System.Windows.Forms.Padding(3, 0, 3, 0);
            this.pnContent2.Size = new System.Drawing.Size(552, 55);
            this.pnContent2.TabIndex = 4;
            // 
            // panelControl2
            // 
            this.panelControl2.Appearance.BackColor = System.Drawing.Color.Transparent;
            this.panelControl2.Appearance.Font = new System.Drawing.Font("Arial", 9F);
            this.panelControl2.Appearance.Options.UseBackColor = true;
            this.panelControl2.Appearance.Options.UseFont = true;
            this.panelControl2.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
            this.panelControl2.Controls.Add(this.lblContent);
            this.panelControl2.Dock = System.Windows.Forms.DockStyle.Fill;
            this.panelControl2.Location = new System.Drawing.Point(54, 0);
            this.panelControl2.Name = "panelControl2";
            this.panelControl2.Padding = new System.Windows.Forms.Padding(3);
            this.panelControl2.Size = new System.Drawing.Size(495, 55);
            this.panelControl2.TabIndex = 4;
            // 
            // lblContent
            // 
            this.lblContent.Appearance.Font = new System.Drawing.Font("Arial", 9F);
            this.lblContent.Appearance.Options.UseFont = true;
            this.lblContent.AutoEllipsis = true;
            this.lblContent.AutoSizeMode = DevExpress.XtraEditors.LabelAutoSizeMode.Vertical;
            this.lblContent.Dock = System.Windows.Forms.DockStyle.Fill;
            this.lblContent.Location = new System.Drawing.Point(3, 3);
            this.lblContent.Name = "lblContent";
            this.lblContent.Size = new System.Drawing.Size(489, 30);
            this.lblContent.TabIndex = 0;
            this.lblContent.Text = "crfjoiuserhgluihvkxnvkjkbksbfvhiukb vu b niuer mnilguiureg ncn vml n bivbnufnl em" +
                "rnc nvm guhn uh ngvhnuhbuh ";
            // 
            // pnIcon
            // 
            this.pnIcon.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
            this.pnIcon.Controls.Add(this.lblIcon);
            this.pnIcon.Dock = System.Windows.Forms.DockStyle.Left;
            this.pnIcon.Location = new System.Drawing.Point(3, 0);
            this.pnIcon.Name = "pnIcon";
            this.pnIcon.Size = new System.Drawing.Size(51, 55);
            this.pnIcon.TabIndex = 3;
            // 
            // lblIcon
            // 
            this.lblIcon.Appearance.BackColor = System.Drawing.Color.Transparent;
            this.lblIcon.Appearance.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.lblIcon.Appearance.Image = global::CommonSLT.Properties.Resources.MsgQuestion1;
            this.lblIcon.Appearance.Options.UseBackColor = true;
            this.lblIcon.Appearance.Options.UseFont = true;
            this.lblIcon.Appearance.Options.UseImage = true;
            this.lblIcon.AutoSizeMode = DevExpress.XtraEditors.LabelAutoSizeMode.None;
            this.lblIcon.Location = new System.Drawing.Point(3, 3);
            this.lblIcon.Name = "lblIcon";
            this.lblIcon.Size = new System.Drawing.Size(45, 45);
            this.lblIcon.TabIndex = 0;
            // 
            // MessageForm
            // 
            this.Appearance.Font = new System.Drawing.Font("Arial", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.Appearance.Options.UseFont = true;
            this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.AutoValidate = System.Windows.Forms.AutoValidate.Disable;
            this.BackgroundImageLayoutStore = System.Windows.Forms.ImageLayout.Stretch;
            this.BackgroundImageStore = global::CommonSLT.Properties.Resources.BGInfo;
            this.ClientSize = new System.Drawing.Size(558, 104);
            this.Controls.Add(this.pnContent);
            this.Controls.Add(this.pnButton);
            this.DoubleBuffered = true;
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
            this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
            this.LookAndFeel.SkinName = "Office 2007 Blue";
            this.LookAndFeel.UseDefaultLookAndFeel = false;
            this.MaximizeBox = false;
            this.MinimumSize = new System.Drawing.Size(448, 25);
            this.Name = "MessageForm";
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
            this.Text = "MessageForm";
            this.Load += new System.EventHandler(this.MessageForm_Load);
            this.Shown += new System.EventHandler(this.MessageForm_Shown);
            this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MessageForm_FormClosing);
            ((System.ComponentModel.ISupportInitialize)(this.pnButton)).EndInit();
            this.pnButton.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.pnButton1)).EndInit();
            this.pnButton1.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.pnCopyToClipboard)).EndInit();
            this.pnCopyToClipboard.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.pnBtnOK)).EndInit();
            this.pnBtnOK.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.pnBtnYes)).EndInit();
            this.pnBtnYes.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.pnBtnNo)).EndInit();
            this.pnBtnNo.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.pnBtnClose)).EndInit();
            this.pnBtnClose.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.pnContent)).EndInit();
            this.pnContent.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.pnContent2)).EndInit();
            this.pnContent2.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.panelControl2)).EndInit();
            this.panelControl2.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.pnIcon)).EndInit();
            this.pnIcon.ResumeLayout(false);
            this.ResumeLayout(false);

        }
        #endregion control
        //==========================================================================

        #region form
        /// <summary>
        /// Hiển thị MessageBox.
        /// - Chỉ hiển thị nút OK
        /// - Ảnh: Info
        /// </summary>
        /// <param name="content">Nội dung.</param>
        public MessageForm(string content)
        {
            InitializeComponent();
            this.mCopyMyDialogMessageToClipBoard = new dgCopyMyDialogMessageToClipBoard(CopyMyDialogMessageToClipBoard);

            this.content = (content.StartsWith("\r\n") ? content : "\r\n" + content);
            this.myDialogButtons = MyDialogButtons.OK;
            this.myDialogFocus = MyDialogFocus.OK;
            this.myDialogResult = MyDialogResult.OK;
        }

        /// <summary>
        /// Hiển thị MessageBox.
        /// - Chỉ hiển thị nút OK
        /// - Ảnh: Info
        /// </summary>
        /// <param name="content">Nội dung.</param>
        /// <param name="caption">Nội dung trên title bar.</param>
        public MessageForm(string content, string caption)
        {
            InitializeComponent();
            this.content = (content.StartsWith("\r\n") ? content : "\r\n" + content);
            this.caption = caption;
            this.myDialogButtons = MyDialogButtons.OK;
            this.myDialogFocus = MyDialogFocus.OK;
            this.myDialogResult = MyDialogResult.OK;
        }

        /// <summary>
        /// Hiển thị MessageBox.
        /// - Ảnh: Info
        /// </summary>
        /// <param name="content">Nội dung.</param>
        /// <param name="caption">Nội dung trên title bar.</param>
        /// <param name="myDialogButtons">Các nút.</param>
        public MessageForm(string content, string caption, MyDialogButtons myDialogButtons)
        {
            InitializeComponent();
            this.content = (content.StartsWith("\r\n") ? content : "\r\n" + content);
            this.caption = caption;
            this.myDialogButtons = myDialogButtons;
            switch (myDialogButtons)
            {
                case MyDialogButtons.OK:
                    this.myDialogFocus = MyDialogFocus.OK;
                    this.myDialogResult = MyDialogResult.OK;
                    break;
                case MyDialogButtons.YesNo:
                    this.myDialogFocus = MyDialogFocus.No;
                    this.myDialogResult = MyDialogResult.No;
                    break;
                case MyDialogButtons.YesNoCancel:
                    this.myDialogFocus = MyDialogFocus.Cancel;
                    this.myDialogResult = MyDialogResult.Cancel;
                    break;
            }
        }

        /// <summary>
        /// Hiển thị MessageBox.
        /// - Ảnh: Info
        /// </summary>
        /// <param name="content">Nội dung.</param>
        /// <param name="caption">Nội dung trên title bar.</param>
        /// <param name="myDialogButtons">Các nút.</param>
        /// <param name="myDialogFocus">Nút sẽ focus.</param>
        public MessageForm(string content, string caption, MyDialogButtons myDialogButtons, MyDialogFocus myDialogFocus)
        {
            InitializeComponent();
            this.content = (content.StartsWith("\r\n") ? content : "\r\n" + content);
            this.caption = caption;
            this.myDialogButtons = myDialogButtons;
            this.myDialogFocus = myDialogFocus;
            switch (myDialogFocus)
            {
                case MyDialogFocus.OK:
                    this.myDialogResult = MyDialogResult.OK;
                    break;
                case MyDialogFocus.Yes:
                    this.myDialogResult = MyDialogResult.Yes;
                    break;
                case MyDialogFocus.No:
                    this.myDialogResult = MyDialogResult.No;
                    break;
                case MyDialogFocus.Cancel:
                    this.myDialogResult = MyDialogResult.Cancel;
                    break;
            }
        }

        /// <summary>
        /// Hiển thị MessageBox.
        /// </summary>
        /// <param name="content">Nội dung.</param>
        /// <param name="caption">Nội dung trên title bar.</param>
        /// <param name="myDialogButtons">Các nút.</param>
        /// <param name="myDialogFocus">Nút sẽ focus.</param>
        /// <param name="myDialogIcon">Ảnh.</param>
        public MessageForm(string content, string caption, MyDialogButtons myDialogButtons, MyDialogFocus myDialogFocus, MyDialogIcon myDialogIcon)
        {
            InitializeComponent();
            this.content = (content.StartsWith("\r\n") ? content : "\r\n" + content);
            this.caption = caption;
            this.myDialogButtons = myDialogButtons;
            this.myDialogFocus = myDialogFocus;
            this.myDialogIcon = myDialogIcon;
            switch (myDialogFocus)
            {
                case MyDialogFocus.OK:
                    this.myDialogResult = MyDialogResult.OK;
                    break;
                case MyDialogFocus.Yes:
                    this.myDialogResult = MyDialogResult.Yes;
                    break;
                case MyDialogFocus.No:
                    this.myDialogResult = MyDialogResult.No;
                    break;
                case MyDialogFocus.Cancel:
                    this.myDialogResult = MyDialogResult.Cancel;
                    break;
            }
        }

        /// <summary>
        /// Hiển thị MessageBox.
        /// </summary>
        /// <param name="content">Nội dung.</param>
        /// <param name="caption">Nội dung trên title bar.</param>
        /// <param name="myDialogButtons">Các nút.</param>
        /// <param name="myDialogIcon">Ảnh.</param>
        public MessageForm(string content, string caption, MyDialogButtons myDialogButtons, MyDialogIcon myDialogIcon)
        {
            InitializeComponent();
            this.content = (content.StartsWith("\r\n") ? content : "\r\n" + content);
            this.caption = caption;
            this.myDialogButtons = myDialogButtons;
            this.myDialogIcon = myDialogIcon;
            switch (myDialogButtons)
            {
                case MyDialogButtons.OK:
                    this.myDialogFocus = MyDialogFocus.OK;
                    this.myDialogResult = MyDialogResult.OK;
                    break;
                case MyDialogButtons.YesNo:
                    this.myDialogFocus = MyDialogFocus.No;
                    this.myDialogResult = MyDialogResult.No;
                    break;
                case MyDialogButtons.YesNoCancel:
                    this.myDialogFocus = MyDialogFocus.Cancel;
                    this.myDialogResult = MyDialogResult.Cancel;
                    break;
            }
        }

        #region form events
        private void MessageForm_Load(object sender, EventArgs e)
        {
            try
            {
                this.Text = this.caption;
                this.lblContent.Text = this.content;
                this.pnBtnClose.Visible = false;
                this.pnBtnNo.Visible = false;
                this.pnBtnOK.Visible = false;
                this.pnBtnYes.Visible = false;
                switch (this.myDialogButtons)
                {
                    case MyDialogButtons.OK:
                        this.pnBtnOK.Visible = true;
                        break;
                    case MyDialogButtons.YesNo:
                        this.pnBtnYes.Visible = true;
                        this.pnBtnNo.Visible = true;
                        break;
                    case MyDialogButtons.YesNoCancel:
                        this.pnBtnYes.Visible = true;
                        this.pnBtnNo.Visible = true;
                        this.pnBtnClose.Visible = true;
                        break;
                }

                switch (this.myDialogIcon)
                {
                    case MyDialogIcon.ALert:
                        this.lblIcon.Appearance.Image = global::CommonSLT.Properties.Resources.MsgAlert1;
                        this.Icon = global::CommonSLT.Properties.Resources.MsgAlert;
                        this.BackgroundImage = global::CommonSLT.Properties.Resources.BGAlert;
                        this.pnCopyToClipboard.Visible = false;
                        break;
                    case MyDialogIcon.Bug:
                        this.lblIcon.Appearance.Image = global::CommonSLT.Properties.Resources.MsgBug1;
                        this.Icon = global::CommonSLT.Properties.Resources.MsgBug;
                        this.BackgroundImage = global::CommonSLT.Properties.Resources.BGError;
                        this.pnCopyToClipboard.Visible = true;
                        break;
                    case MyDialogIcon.Connect:
                        this.lblIcon.Appearance.Image = global::CommonSLT.Properties.Resources.MsgConnect1;
                        this.Icon = global::CommonSLT.Properties.Resources.MsgConnect;
                        this.BackgroundImage = global::CommonSLT.Properties.Resources.BGError;
                        this.pnCopyToClipboard.Visible = false;
                        break;
                    case MyDialogIcon.Error:
                        this.lblIcon.Appearance.Image = global::CommonSLT.Properties.Resources.MsgError1;
                        this.Icon = global::CommonSLT.Properties.Resources.MsgError;
                        this.BackgroundImage = global::CommonSLT.Properties.Resources.BGError;
                        this.pnCopyToClipboard.Visible = true;
                        break;
                    case MyDialogIcon.Info:
                        this.lblIcon.Appearance.Image = global::CommonSLT.Properties.Resources.MsgInfo1;
                        this.Icon = global::CommonSLT.Properties.Resources.MsgInfo;
                        this.BackgroundImage = global::CommonSLT.Properties.Resources.BGInfo;
                        this.pnCopyToClipboard.Visible = false;
                        break;
                    case MyDialogIcon.Question:
                        this.lblIcon.Appearance.Image = global::CommonSLT.Properties.Resources.MsgQuestion1;
                        this.Icon = global::CommonSLT.Properties.Resources.MsgQuestion;
                        this.BackgroundImage = global::CommonSLT.Properties.Resources.BGQuestion;
                        this.pnCopyToClipboard.Visible = false;
                        break;
                    case MyDialogIcon.None:
                        this.pnIcon.Visible = false;
                        this.Icon = global::CommonSLT.Properties.Resources.MsgInfo;
                        this.BackgroundImage = global::CommonSLT.Properties.Resources.BGInfo;
                        this.pnCopyToClipboard.Visible = false;
                        break;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Lỗi:\r\n" + ex.Message);
            }
        }

        private void MessageForm_Shown(object sender, EventArgs e)
        {
            switch (this.myDialogFocus)
            {
                case MyDialogFocus.Cancel:
                    this.btnClose.Focus();
                    break;
                case MyDialogFocus.Yes:
                    this.btnYes.Focus();
                    break;
                case MyDialogFocus.No:
                    this.btnNo.Focus();
                    break;
                case MyDialogFocus.OK:
                    this.btnOK.Focus();
                    break;
            }
            ResizeControl();
        }

        private void MessageForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            try
            {
                MyDialogEventArgs evt = new MyDialogEventArgs(this.myDialogResult);
                if (MyDialogEvent != null)
                    MyDialogEvent(this, evt);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Lỗi khi đóng:\r\n" + ex.Message);
            }
        }
        #endregion form events
        #endregion form
        //==========================================================================

        #region private function
        private void btnCopyToClipboard_Click(object sender, EventArgs e)
        {
            this.Invoke(this.mCopyMyDialogMessageToClipBoard);
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            this.myDialogResult = MyDialogResult.OK;
            this.Close();
        }

        private void btnYes_Click(object sender, EventArgs e)
        {
            this.myDialogResult = MyDialogResult.Yes;
            this.Close();
        }

        private void btnNo_Click(object sender, EventArgs e)
        {
            this.myDialogResult = MyDialogResult.No;
            this.Close();
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            this.myDialogResult = MyDialogResult.Cancel;
            this.Close();
        }

        private void ResizeControl()
        {
            Graphics graphics = lblContent.CreateGraphics();
            string[] s = lblContent.Text.Split('\n');
            SizeF textSize = new SizeF();
            int row = 0;
            for (int i = 0; i < s.Length; i++)
            {
                row++;
                s[i] = s[i].Replace("\r", "");
                s[i] = s[i].Replace("\n", "");
                textSize = graphics.MeasureString(s[i], lblContent.Font);
                if (textSize.Width > 455)
                    row += (int)textSize.Width / 455 + ((int)textSize.Width % 455 > 0 ? 1 : 0);
            }
            if (row > 3)
                this.Height += ((int)textSize.Height) * (row - 3);
            if (this.Height > 600)
                this.Height = 600;
        }

        private void CopyMyDialogMessageToClipBoard()
        {
            Clipboard.SetText(this.caption + "\r\n" + this.content);
        }
        #endregion private function
        //==========================================================================
    }
}
